﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    //用户信息

    public class UsersInfoServices
    {
        
            //查询
            public static List<UsersInfo> Select()
            {
                string sql = "select * from Users u,uInformation ui where u.uuiId=ui.uiId ";
                DataTable dt = DBHelper.GetDataTable(sql);
                List<UsersInfo> usersInfo = new List<UsersInfo>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    UsersInfo ui = new UsersInfo()
                    {
                        Id = Convert.ToInt32(dt.Rows[i]["Id"].ToString()),
                        uNickname = dt.Rows[i]["uNickname"].ToString(),
                        uPassword = dt.Rows[i]["uPassword"].ToString(),
                        uEmail = dt.Rows[i]["uEmail"].ToString(),
                        uName = dt.Rows[i]["uName"].ToString(),
                        uTelephone = dt.Rows[i]["uTelephone"].ToString(),
                        uAddress = dt.Rows[i]["uAddress"].ToString(),
                        uuiId = Convert.ToInt32(dt.Rows[i]["uuiId"].ToString())
                    };
                    usersInfo.Add(ui);
                }
                return usersInfo;
            }
            //删除
            public static bool Delete(int id)
            {
                string sql = "delete from Users where Id=" + id;
                bool result = DBHelper.ExecuteNonQuery(sql);
                return result;
            }
        
    }
}
